﻿<Page
    x:Name="pageRoot"
    x:Class="SmartPatientCentre.Pages.Results"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SmartPatientCentre.Pages"
    xmlns:common="using:SmartPatientCentre.Common"
    xmlns:oxy="using:OxyPlot.Metro"
    xmlns:vm="using:SmartPatientCentre.ViewModels"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        
        <!-- Binding sources for result lists -->
        <CollectionViewSource
        x:Name="latestResults"
        Source="{Binding LatestResults}"/>

        <CollectionViewSource
        x:Name="sodiumResults"
        Source="{Binding SodiumResults}"/>

        <CollectionViewSource
        x:Name="potassiumResults"
        Source="{Binding PotassiumResults}"/>

        <CollectionViewSource
        x:Name="ureaResults"
        Source="{Binding UreaResults}"/>

        <CollectionViewSource
        x:Name="creatinineResults"
        Source="{Binding CreatinineResults}"/>

    </Page.Resources>

    <!-- Top AppBar -->
    <Page.TopAppBar>
        <CommandBar>
            <AppBarButton Label="Logout" Icon="Clear" Click="LogoutButtonClick" />
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Dashboard" Icon="Home" Click="DashboardButtonClick" />
                <AppBarButton Label="My Patients" Icon="ContactInfo" Click="MyPatientsButtonClick" />
                <AppBarButton Label="All Patients" Icon="ViewAll" Click="AllPatientsButtonClick" />
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.TopAppBar>

    <!-- Content Grid -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        
        <!-- Hub Control -->
        <Hub SectionHeaderClick="HubSectionHeaderClick">

            <!-- Patient Info Header -->
            <Hub.Header> 
                <Grid Margin="-35,-55,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="120"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    
                    <!-- Back Button -->
                    <Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>

                    <!-- Patient Tile -->
                    <Grid DataContext="{Binding Patient}" Grid.Column="1" HorizontalAlignment="Left" Width="300">
                        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Background="#FFEEEEEE" Margin="0,30,0,0">
                            <Border Background="{Binding GenderColor}" Height="100" Width="100">
                                <TextBlock Text="{Binding Initials}" Style="{StaticResource HeaderTextBlockStyle}" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" />
                            </Border>
                            <StackPanel Width="200" VerticalAlignment="Center">
                                <TextBlock Text="{Binding FullName}" Style="{StaticResource TitleTextBlockStyle}" HorizontalAlignment="Center" FontWeight="Bold"/>
                                <TextBlock Text="{Binding Ward}" Style="{StaticResource SubtitleTextBlockStyle}" HorizontalAlignment="Center"/>
                                <TextBlock Text="{Binding RoomBed}" Style="{StaticResource SubtitleTextBlockStyle}" HorizontalAlignment="Center"/>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                                                                
                </Grid>
            </Hub.Header>

            <!-- Latest Results Section -->
            <HubSection Header="Latest" Margin="82,20,0,0" >
                <DataTemplate>
                    <GridView
                        AutomationProperties.AutomationId="ItemsGridView"
                        AutomationProperties.Name="Items"
                        ItemsSource="{Binding Source={StaticResource latestResults}}"
                        ItemTemplate="{StaticResource ResultTile}"
                        IsItemClickEnabled="True"
                        ItemClick="LatestItemClick"
                        SelectionMode="None"
                        IsSwipeEnabled="false" 
                        Padding="0,0,0,10" />
                </DataTemplate>
            </HubSection>
            
            <!-- Sodium Results Section -->
            <HubSection IsHeaderInteractive="True" Header="Sodium" Margin="0,20,0,0">
                <DataTemplate>
                    <GridView
                        AutomationProperties.AutomationId="ItemsGridView"
                        AutomationProperties.Name="Items"
                        ItemsSource="{Binding Source={StaticResource sodiumResults}}"
                        ItemTemplate="{StaticResource ResultTile}"
                        SelectionMode="None"
                        IsSwipeEnabled="false" >
                    </GridView>
                </DataTemplate>
            </HubSection>

            <!-- Potassium Results Section -->
            <HubSection IsHeaderInteractive="True" Header="Potassium" Margin="0,20,0,0">
                <DataTemplate>
                    <GridView
                        AutomationProperties.AutomationId="ItemsGridView"
                        AutomationProperties.Name="Items"
                        ItemsSource="{Binding Source={StaticResource potassiumResults}}"
                        ItemTemplate="{StaticResource ResultTile}"
                        SelectionMode="None"
                        IsSwipeEnabled="false" >
                    </GridView>
                </DataTemplate>
            </HubSection>

            <!-- Urea Results Section -->
            <HubSection IsHeaderInteractive="True" Header="Urea" Margin="0,20,0,0">
                <DataTemplate>
                    <GridView
                        ItemsSource="{Binding Source={StaticResource ureaResults}}"
                        ItemTemplate="{StaticResource ResultTile}"
                        SelectionMode="None"
                        IsSwipeEnabled="false" >
                    </GridView>
                </DataTemplate>
            </HubSection>

            <!-- Creatinine Results Section -->
            <HubSection IsHeaderInteractive="True" Header="Creatinine" Margin="0,20,0,0">
                <DataTemplate>
                    <GridView
                        ItemsSource="{Binding Source={StaticResource creatinineResults}}"
                        ItemTemplate="{StaticResource ResultTile}"
                        SelectionMode="None"
                        IsSwipeEnabled="false" >
                    </GridView>
                </DataTemplate>
            </HubSection>

            <!-- Sodium Chart --><!--
            <HubSection Header="Sodium Chart">
                <DataTemplate>
                    <Grid DataContext="{Binding SodiumChart}">
                        <oxy:Plot Model="{Binding Model}" Height="400" Width="400" />
                    </Grid>
                </DataTemplate>
            </HubSection>

            --><!-- Potassium Chart --><!--
            <HubSection Header="Potassium Chart">
                <DataTemplate>
                    <Grid DataContext="{Binding PotassiumChart}">
                        <oxy:Plot Model="{Binding Model}" Height="600" Width="600" />
                    </Grid>
                </DataTemplate>
            </HubSection>

            --><!-- Urea Chart --><!--
            <HubSection Header="Urea Chart">
                <DataTemplate>
                    <Grid DataContext="{Binding UreaChart}">
                        <oxy:Plot Model="{Binding Model}" Height="600" Width="600" />
                    </Grid>
                </DataTemplate>
            </HubSection>

            --><!-- Creatinine Chart --><!--
            <HubSection Header="Creatinine Chart">
                <DataTemplate>
                    <Grid DataContext="{Binding CreatinineChart}">
                        <oxy:Plot Model="{Binding Model}" Height="600" Width="600" />
                    </Grid>
                </DataTemplate>
            </HubSection>

            --><!-- Example Chart --><!--
            <HubSection Header="Example Chart">
                <DataTemplate>
                    <Grid>
                        <Grid.DataContext>
                            <vm:FunctionViewModel />
                        </Grid.DataContext>
                        <oxy:Plot Model="{Binding MyModel}" Height="350" Width="350" />
                    </Grid>
                </DataTemplate>
            </HubSection>-->

        </Hub>
        
    </Grid>
</Page>
